﻿@model IEnumerable<S4sme.Domain.Post>
@{
    ViewBag.Title = "Index";
    Layout = "../Shared/_AdminLayout.cshtml";
}

<h2>Index</h2>

<table>
    <tr>
        <th>
            Title
        </th>
        <th>
            Description
        </th>
        <th>
            Content
        </th>
        <th>
            Categories
        </th>
        <th>
            Tags
        </th>
        <th>
            Comments
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @item.Title
            </td>
            <td>
                @item.Description
            </td>
            <td>
                @item.Content
            </td>
            <td>
                @foreach (var category in item.Categories) {
                    @category.Name<br />
                }
            </td>
            <td>
                @foreach (var tag in item.Tags) {
                    @tag.Name<br />
                }
            </td>
            <td>
                @foreach (var comment in item.Comments) {
                    @comment.Author<br />
                    @comment.Email<br />
                    @comment.Content<br />
                }
            </td>
            <td>
                @Html.ActionLink("Edit", "EditPost", new { id = item.Id }) |
                @Html.ActionLink("Details", "Details", "Post", new { id = item.Id }, null) |

                @using (Html.BeginForm("Delete", "DeletePost", FormMethod.Post, new { style = "display:inline" })) {
                    @Html.AntiForgeryToken()
                    @Html.Hidden("id", item.Id)
                    <input type="submit" value="Delete" />
                }
            </td>
        </tr>
    }
</table>

<p>
    @Html.ActionLink("Create New", "CreatePost")
</p>


<p>@Html.Action("Categories", "Admin")</p>
<p>@Html.Action("Tags", "Admin")</p>


